﻿using System;

namespace Alex.Library.Log
{
    /// <summary>
    /// 默认的模板
    /// </summary>
    public sealed class DefaultTemplate : ILogInfoTemplate
    {
        private string TEMP = "{level} at {time}:\r\n{message}\r\n----------------------------------------\r\n";
        /// <summary>
        /// 模板内容
        /// </summary>
        public string Content
        {
            get { return TEMP; }
        }

        /// <summary>
        /// 使用模板格式化输出信息
        /// </summary>
        /// <param name="level">日志级别</param>
        /// <param name="message">日志消息</param>
        /// <returns></returns>
        public string Format(LogLevel level, string message)
        {
            return TEMP.Replace("{level}", level.ToString())
                       .Replace("{time}", String.Format("{0:yyyy/MM/dd HH:mm:ss}", DateTime.Now))
                       .Replace("{message}", message);
        }
    }
}
